package com.app.micaihu.view.utils;


import androidx.collection.ArrayMap;

import java.net.URLEncoder;
import kotlin.text.Charsets;

/**
 * Created by
 * <p>
 * HashMap的包装类,将所有put的value进行utf-8的编码
 */
public class ParamsMap extends ArrayMap<String, Object> {

    public Object putValue(String key, Object value) {
        if (value == null) {
            return "";
        }
        String encodeVal;
        try {
//            encodeVal = URLEncoder.encode(String.valueOf(value), String.valueOf(Charsets.UTF_8));
            encodeVal = String.valueOf(value);
        } catch (Exception e) {
            e.printStackTrace();
            encodeVal = "";
        }
        return super.put(key, encodeVal);
    }

}